var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("AssetsMap"),
    c = e("GameData"),
    l = e("PlayerLevel"),
    d = e("MapScrollview"),
    u = cc._decorator,
    p = u.ccclass,
    h = u.property,
    f = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.items = []),
                (t.mapScrollview = null),
                (t.themeNameLabel = null),
                (t.startBtn = null),
                (t.themeName = ["动物森林", "魔法世界", "水果派对", "奇幻乐园"]),
                (t.openCondition = [0, 145, 313, 545]),
                (t.userLevel = 0),
                t
            );
        }
        return (
            a(t, e),
            (t.prototype.onLoad = function () {
                this.isCache = !1;
            }),
            (t.prototype.onResetView = function () {
                e.prototype.onResetView.call(this),
                    this.mapScrollview.init(),
                    this.mapScrollview.registerIndexSkipEvent(this.listSkip, this),
                    (this.userLevel = l.default.instance.score),
                    ad.curr_platform === window.ad.Platform.VIVO && ad.adInterface.hideGamePortal(!1);
                for (var t = 0, o = 0; o < this.items.length; o++)
                    this.mapScrollview.addPage(this.items[o]),
                        (this.items[o].active = !0),
                        this.userLevel >= this.openCondition[o] && (t = o),
                        this.renderItem(this.items[o], this.userLevel >= this.openCondition[o]);
                t > 0 && this.mapScrollview.judgeSkipOut(t), this.renderInfo(t);
            }),
            (t.prototype.addEvent = function () {
                e.prototype.addEvent.call(this),
                    this.startBtn.on(game.EngineEventType.NodeEvent.click, this.clickStart, this);
            }),
            (t.prototype.removeEvent = function () {
                e.prototype.removeEvent.call(this),
                    this.startBtn.off(game.EngineEventType.NodeEvent.click, this.clickStart, this);
            }),
            (t.prototype.clickStart = function () {
                (c.default.instance.GameModel = c.GameModel.TimeLimit),
                    (c.default.instance.themeIndex = this.mapScrollview.getCurrentIndex() + 1),
                    this.onClickJoinGame();
            }),
            (t.prototype.listSkip = function (e, t) {
                this.renderInfo(t);
            }),
            (t.prototype.renderInfo = function (e) {
                (this.themeNameLabel.string = this.themeName[e]),
                    (this.startBtn.active = this.userLevel >= this.openCondition[e]);
            }),
            (t.prototype.renderItem = function (e, t) {
                (e.getChildByName("lock").active = !t), (e.getChildByName("font").active = !t);
                var o = t ? cc.Color.WHITE : new cc.Color(116, 116, 116);
                e.getChildByName("item").color = o;
            }),
            (t.prototype.onClickJoinGame = function () {
                var e = !1,
                    t = {isReadyPatch: e};
                ad.curr_platform === window.ad.Platform.OPPO &&
                ((e = ad.adInterface.isNativePatchReady()), (t.isReadyPatch = e), e)
                    ? game.PopupManager.instance.showPopView(s.default.PopupMap.SkinTrialView_Oppo, t, !1, !1)
                    : game.PopupManager.instance.showPopView(s.default.PopupMap.SkinTrialView, t, !1, !1);
            }),
            (t.prototype.closeView = function (t) {
                void 0 === t && (t = !0),
                    e.prototype.closeView.call(this, t),
                    ad.curr_platform === window.ad.Platform.VIVO && ad.adInterface.showGamePortal();
            }),
            r([h([cc.Node])], t.prototype, "items", void 0),
            r([h(d.default)], t.prototype, "mapScrollview", void 0),
            r([h(cc.Label)], t.prototype, "themeNameLabel", void 0),
            r([h(cc.Node)], t.prototype, "startBtn", void 0),
            r([p], t)
        );
    })(game.BasePopView);
i.default = f;
